package com.kitty.spring.kittyUnifiedProcess.controller;

import com.kitty.spring.kittyUnifiedProcess.commons.BaseResult;
import com.kitty.spring.kittyUnifiedProcess.model.Info;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

/**
 * @Description swagger接口文档测试
 * @Author SHEN
 * @Date 2020/10/13
 */
@RestController
@Api(tags = "api测试相关接口")
@RequestMapping("/api")
public class TestController {
    private static final Logger LOGGER = LoggerFactory.getLogger(TestController.class);

    @PostMapping("/add")
    @ApiOperation("添加接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "姓名")
    })
    public BaseResult addInfo(String name) {
        Info info = new Info();
        info.setId(12345);
        info.setAge(14);
        info.setName(name);

        return BaseResult.ok().put(info);
    }

    @GetMapping("/{id}")
    @ApiOperation("根据id查询信息的接口")
    @ApiImplicitParam(name = "id", value = "ID", required = true)
    public BaseResult getInfoById(@PathVariable Integer id) {
        LOGGER.debug("信息查询成功");
        return BaseResult.ok();
    }

    @DeleteMapping("/{id}")
    @ApiOperation("根据id删除信息的接口")
    @ApiImplicitParam(name = "id", value = "ID", required = true)
    public BaseResult deleteInfoById(@PathVariable Integer id) {
        return BaseResult.ok();
    }
    @PutMapping("/{id}")
    @ApiOperation("根据id更新信息的接口")
    public BaseResult updateInfoById(@PathVariable Integer id, @RequestBody Info info) {
        return BaseResult.ok();
    }
}
